﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KCMS.DataAcsess.Interfaces;
using StructureMap;
using AutoMapper;
using KCMS.BusinessLogic.Models;
using KCMS.BusinessLogic.Interfaces;


namespace KCMS.BusinessLogic.Engine
{
    public class AllowableProductSizeService:IAllowableProductSizeService
    {
        private IAllowableProductSizeManager allowableProductSizeManager = ObjectFactory.GetInstance<IAllowableProductSizeManager>();
        public Models.AllowableProductSize getById(Guid id)
        {
            DataAcsess.Entitys.AllowableProductSizeEntity allowableProductAllowableProductSizeEntity = allowableProductSizeManager.getById(id);
            return Mapper.Map<DataAcsess.Entitys.AllowableProductSizeEntity, Models.AllowableProductSize>(allowableProductAllowableProductSizeEntity);
        }
       
        public IEnumerable<Models.AllowableProductSize> getAll()
        {
            var model = from t in allowableProductSizeManager.getAll()
                        select t;
            return Mapper.Map<IEnumerable<DataAcsess.Entitys.AllowableProductSizeEntity>, IEnumerable<Models.AllowableProductSize>>(model);

        }

        public void update(AllowableProductSize allowableProductAllowableProductSize)
        {
            allowableProductSizeManager.update(Mapper.Map<AllowableProductSize, DataAcsess.Entitys.AllowableProductSizeEntity>(allowableProductAllowableProductSize));
        }


        public void save(AllowableProductSize allowableProductAllowableProductSize)
        {
            allowableProductSizeManager.save(Mapper.Map<AllowableProductSize, DataAcsess.Entitys.AllowableProductSizeEntity>(allowableProductAllowableProductSize));
        }


        public void delete(Guid id)
        {
            allowableProductSizeManager.delete(id);
        }


        public IEnumerable<AllowableProductSize> getByProduct(Guid productId)
        {
            return (from t in getAll()
                    where t.ProductId.Equals(productId)
                    select t).ToList();
        }
    }
}
